#include "resourcemonitorinfo.h"

ResourceMonitorInfo::ResourceMonitorInfo(QObject *parent)
    : QObject{parent}
{
}

QJsonObject ResourceMonitorInfo::toJsonObject() const
{
    QJsonObject obj;
    obj.insert("serverInfo", serverInfo.toJsonObject(QBaseEntity::IgnoreOutProperty, {"createTime", "updateTime"}));

    QJsonArray cpuInfoArray;
    for (const CpuInfo &info : cpuInfos)
    {
        cpuInfoArray.append(info.toJsonObject(QBaseEntity::IgnoreOutProperty, {"createTime", "updateTime"}));
    }
    obj.insert("cpuInfos", cpuInfoArray);
    QJsonArray cpuUseArray;
    for (const CpuUse &use : cpuUses)
    {
        cpuUseArray.append(use.toJsonObject(QBaseEntity::IgnoreOutProperty, {"createTime", "updateTime"}));
    }
    obj.insert("cpuUses", cpuUseArray);

    QJsonArray memoryInfoArray;
    for (const MemoryInfo &info : memoryInfos)
    {
        memoryInfoArray.append(info.toJsonObject(QBaseEntity::IgnoreOutProperty, {"createTime", "updateTime"}));
    }
    obj.insert("memoryInfos", memoryInfoArray);

    QJsonArray memoryUseArray;
    for (const MemoryUse &use : memoryUses)
    {
        memoryUseArray.append(use.toJsonObject(QBaseEntity::IgnoreOutProperty, {"createTime", "updateTime"}));
    }
    obj.insert("memoryUses", memoryUseArray);
    QJsonArray diskInfoArray;
    for (const DiskInfo &info : diskInfos)
    {
        diskInfoArray.append(info.toJsonObject(QBaseEntity::IgnoreOutProperty, {"createTime", "updateTime"}));
    }
    obj.insert("diskInfos", diskInfoArray);
    QJsonArray diskUseArray;
    for (const DiskUse &use : diskUses)
    {
        diskUseArray.append(use.toJsonObject(QBaseEntity::IgnoreOutProperty, {"createTime", "updateTime"}));
    }
    obj.insert("diskUses", diskUseArray);
    return obj;
}

QList<CpuInfo> ResourceMonitorInfo::getCpuInfos() const
{
    return cpuInfos;
}

void ResourceMonitorInfo::setCpuInfos(const QList<CpuInfo> &newCpuInfos)
{
    cpuInfos = newCpuInfos;
}

QList<CpuUse> ResourceMonitorInfo::getCpuUses() const
{
    return cpuUses;
}

void ResourceMonitorInfo::setCpuUses(const QList<CpuUse> &newCpuUses)
{
    cpuUses = newCpuUses;
}

QList<MemoryInfo> ResourceMonitorInfo::getMemoryInfos() const
{
    return memoryInfos;
}

void ResourceMonitorInfo::setMemoryInfos(const QList<MemoryInfo> &newMemoryInfos)
{
    memoryInfos = newMemoryInfos;
}

QList<MemoryUse> ResourceMonitorInfo::getMemoryUses() const
{
    return memoryUses;
}

void ResourceMonitorInfo::setMemoryUses(const QList<MemoryUse> &newMemoryUses)
{
    memoryUses = newMemoryUses;
}

QList<DiskInfo> ResourceMonitorInfo::getDiskInfos() const
{
    return diskInfos;
}

void ResourceMonitorInfo::setDiskInfos(const QList<DiskInfo> &newDiskInfos)
{
    diskInfos = newDiskInfos;
}

QList<DiskUse> ResourceMonitorInfo::getDiskUses() const
{
    return diskUses;
}

void ResourceMonitorInfo::setDiskUses(const QList<DiskUse> &newDiskUses)
{
    diskUses = newDiskUses;
}

ServerInfo ResourceMonitorInfo::getServerInfo() const
{
    return serverInfo;
}

void ResourceMonitorInfo::setServerInfo(const ServerInfo &newServerInfo)
{
    serverInfo = newServerInfo;
}
